typedef struct _class{
  struct _class *cls;
  int size;
  struct _class *sub[0];
} class;
class typetype = {&typetype, 2},
  booltype = {&typetype, 2},
  inttype = {&typetype, 2},
  stringtype = {&typetype, 2},
  tupletype = {&typetype, 0},
  funtype = {&typetype, 2};
class btrue = {&booltype, 1},
  bfalse = {&booltype, 0};

void pyprint(int nl, int size, class *out){
  class **outs = &out;
  while(size--)
    if(outs[size]->cls == &inttype || outs[size]->cls == &booltype)
      printf("%i ", outs[size]->size);
    else if(outs[size]->cls == &tupletype){
      printf("(");
      for(int i = 0 ; i < outs[size]->size ; i++){
	pyprint(false, 1, outs[size]->sub[i]);
	printf(", ");
      }
      printf(") ");
    }else if(outs[size]->cls == &stringtype)
      printf("%s ", (char *) outs[size]->size);
    else
      printf(". ");
  if(nl)
    printf("\n");
}


/*
typedef struct{
  tree *id;
  void *safeword;
  int safeidx;
} attrlookup;
typedef struct _pyclass{
  struct _pyclass *cls;
  int objsize, clssize, vsize, bsize;
  attrlookup sattr[];
  struct{
    tree *id;
    void *code;
  } vtbl[];
  struct _pyclass bases[], linbases[];
  void *safetbl[0];
} pyclass;

//Python C3 Method resolution 
void mro(pyclass *cls){
  int i;
  pyclass baselins[cls->bsize][], *cur = cls;
  for(i = 0 ; i < cls->bsize ; i++)
    baselins[i] = cls->linbases;
  for(i = 0 ; i < cls->bsize ; i++)
    for(pyclass lin[] = baselins[i] ; *lin ; lin++)
      if(*lin == cur) printf("cyclic class hierachy\n");
 outer:
  for(i = 0 ; i < cls->bsize ; i++){
    cur = baselins[i][0];
    if(!cur) continue;
    for(j = 0 ; j < cls->bsize ; j++)
      for(pyclass lin[] = baselins[j] + 1 ; *lin ; lin++)
	if(*lin == cur) continue outer;
    baselins[i]++;
    i = -1;
    printf("next class: %p\n", cur);
  }
}
*/
